/***********************************************************************************************************************
 *  FILE DESCRIPTION
 *  ------------------------------------------------------------------------------------------------------------------*/
/** \file
 *  \brief         Interrupt vector table module for Renesas RH850 RSCan
 *
 *
 *  --------------------------------------------------------------------------------------------------------------------
 *  COPYRIGHT
 *  --------------------------------------------------------------------------------------------------------------------
 *  \par Copyright
 *  \verbatim
 *  Copyright (c) 2016 by Vector Informatik GmbH.                                                  All rights reserved.
 *
 *                This software is copyright protected and proprietary to Vector Informatik GmbH.
 *                Vector Informatik GmbH grants to you only those rights as set out in the license conditions.
 *                All other rights remain with Vector Informatik GmbH.
 *  \endverbatim
 */
/**********************************************************************************************************************/

/***********************************************************************************************************************
 *  AUTHOR IDENTITY
 *  --------------------------------------------------------------------------------------------------------------------
 *  Name                          Initials      Company
 *  --------------------------------------------------------------------------------------------------------------------
 *  Robert Schaeffner             Rr            Vector Informatik GmbH
 *  Christian Baeuerle            CB            Vector Informatik GmbH
 *  Quetty Palacios               QPs           Vector Informatik GmbH
 *  Fadie Ghraib                  FGh           Vector CANtech, Inc.
 *  --------------------------------------------------------------------------------------------------------------------
 *  REVISION HISTORY
 *  --------------------------------------------------------------------------------------------------------------------
 *  Version    Date        Author  Change Id        Description
 *  --------------------------------------------------------------------------------------------------------------------
 *  01.00.00   2013-06-07  CB                       Creation
 *  01.01.00   2014-05-22  CB      ESCAN00075845    Added support for WindRiver/Diabdata compiler
 *  01.02.00   2015-05-06  QPs     ESCAN00082825    No changes
 *  01.03.00   2016-02-26  FGh     ESCAN00088604    Added support for RH850/IAR use case.
 **********************************************************************************************************************/

/***********************************************************************************************************************
 *  INCLUDES
 **********************************************************************************************************************/
#include "fbl_inc.h"

/***********************************************************************************************************************
 *   VERSION
 **********************************************************************************************************************/

/* ##V_CFG_MANAGEMENT ##CQProject : FblVtab_Rh850 CQComponent : Implementation */
#define FBLVTAB_RH850_VERSION           0x0103
#define FBLVTAB_RH850_RELEASE_VERSION   0x00

#if (FBLVTAB_RH850_VERSION != _FBLVTAB_HW_VERSION) ||\
    (FBLVTAB_RH850_RELEASE_VERSION != _FBLVTAB_HW_RELEASE_VERSION)
# error "Error in FBL_VECT.C: Source and V_VER.H are inconsistent!"
#endif

#if defined(V_COMP_DIABDATA_RH850)
  #define ___asm(c)               __asm_(c)
  #define __asm_(c)               asm(" " #c);
  #define __as1(c, d)             __as1_(c, d)
  #define __as1_(c, d)            asm(" " #c " , " #d);
  #define __as2(c, d, e)          __as2_(c, d, e)
  #define __as2_(c, d, e)         asm(" " #c " , " #d " , " #e);
  #define lp                      r31
  #define FBL_ISR_BASE_ENTRY(x)   ___asm(jr x)

  /* The number of nops is deliberately 5. One nop/alignment is generated by the compiler */ 
  #define FBL_ISR_ALIGNMENT       ___asm(nop) ___asm(nop) ___asm(nop) ___asm(nop) ___asm(nop)

  #define FBL_ISR_ENTRY(x)        ___asm(.word x)
  #define FBL_ISR_KEYWORD         __interrupt__
#elif defined(V_COMP_GHS_RH850) ||\
      defined(V_COMP_IAR_RH850)
  #define ___asm(c)               __asm_(c)
  #define __asm_(c)               asm(" " #c);
  #define __as1(c, d)             __as1_(c, d)
  #define __as1_(c, d)            asm(" " #c " , " #d);
  #define __as2(c, d, e)          __as2_(c, d, e)
  #define __as2_(c, d, e)         asm(" " #c " , " #d " , " #e);
  #define FBL_ISR_BASE_ENTRY(x)   ___asm(jr x)
  #define FBL_ISR_ALIGNMENT       ___asm(nop);___asm(nop);___asm(nop);___asm(nop);___asm(nop);___asm(nop);
  #define FBL_ISR_ENTRY(x)        ___asm(.word x)
  #define FBL_ISR_KEYWORD         __interrupt
#endif

/*****************************************************************************/
/* Implementation                                                            */
/*****************************************************************************/

/* Alignment and section declaration*/
#if defined (V_COMP_GHS_RH850)
___asm(.align 4)
__as1(.section ".intvect",.text)
#elif defined (V_COMP_DIABDATA_RH850)
___asm(.section .intvect)
___asm(.alignn 4)
#endif

/* -- interrupt vectors */
___asm(_reset:)
___asm(.globl _reset)
/* -- RESET                        0x0000: */
    FBL_ISR_BASE_ENTRY(__usr_init)
    FBL_ISR_ALIGNMENT

/* -- SYSERR                       0x0010: */
    FBL_ISR_BASE_ENTRY(__usr_init)
    FBL_ISR_ALIGNMENT

/* -- HVTRAP                       0x0020: */
    FBL_ISR_BASE_ENTRY(__usr_init)
    FBL_ISR_ALIGNMENT

/* -- FETRAP                       0x0030: */
    FBL_ISR_BASE_ENTRY(__usr_init)
    FBL_ISR_ALIGNMENT

/* -- TRAP0                        0x0040: */
    FBL_ISR_BASE_ENTRY(__usr_init)
    FBL_ISR_ALIGNMENT

/* -- TRAP1                        0x0050: */
    FBL_ISR_BASE_ENTRY(__usr_init)
    FBL_ISR_ALIGNMENT

/* -- RIE                          0x0060: */
    FBL_ISR_BASE_ENTRY(__usr_init)
    FBL_ISR_ALIGNMENT

/* -- FPP/FPI                      0x0070: */
    FBL_ISR_BASE_ENTRY(__usr_init)
    FBL_ISR_ALIGNMENT

/* -- UCPOP                        0x0080: */
    FBL_ISR_BASE_ENTRY(__usr_init)
    FBL_ISR_ALIGNMENT

/* -- MIP/MDP/...                  0x0090: */
    FBL_ISR_BASE_ENTRY(__usr_init)
    FBL_ISR_ALIGNMENT

/* -- PIE                          0x00A0: */
    FBL_ISR_BASE_ENTRY(__usr_init)
    FBL_ISR_ALIGNMENT

/* -- DEBUG                        0x00B0: */
    FBL_ISR_BASE_ENTRY(__usr_init)
    FBL_ISR_ALIGNMENT

/* -- MAE                          0x00C0: */
    FBL_ISR_BASE_ENTRY(__usr_init)
    FBL_ISR_ALIGNMENT

/* -- (R.F.U)                      0x00D0: */
    FBL_ISR_BASE_ENTRY(__usr_init)
    FBL_ISR_ALIGNMENT

/* -- FENMI                        0x00E0: */
    FBL_ISR_BASE_ENTRY(__usr_init)
    FBL_ISR_ALIGNMENT

/* -- FEINT                        0x00F0: */
    FBL_ISR_BASE_ENTRY(__usr_init)


/***********************************************************************************************************************
 *  END OF FILE: FBL_VECT.C
 **********************************************************************************************************************/
